package org.yuyao.biz1.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yuyao.biz1.service.UserService;
import org.yuyao.common.domain.vo.YuyaoResponse;
import org.yuyao.security.annotation.RequiresLogin;
import org.yuyao.security.annotation.RequiresPermissions;
import org.yuyao.security.annotation.RequiresRoles;

@RestController
public class LoginController {

    @Autowired
    private UserService userService;

    @RequiresLogin
    @GetMapping("/public/nologin")
    public YuyaoResponse nologin() {

        String usernmae=userService.findUserName();
        return YuyaoResponse.success("无需登录页面"+usernmae);
    }
    @RequiresRoles({"admin","zmx"})
    @GetMapping("/public/nologin1")
    public YuyaoResponse nologin1() {

        String usernmae=userService.findUserName();
        return YuyaoResponse.success("无需登录页面"+usernmae);
    }

    @RequiresPermissions({"user:login","user:add"})
    @GetMapping("/login")
    public YuyaoResponse login(String username, String password) {
        return YuyaoResponse.success("登录");
    }

    @GetMapping("/logout")
    public YuyaoResponse logout() {
        return YuyaoResponse.success("注销登录页");
    }

}
